# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=c-ares
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.11.0
pkgrel=1
pkgdesc="C library that performs DNS requests and name resolves asynchronously (mingw-w64)"
arch=('any')
url="http://c-ares.haxx.se/"
license=("MIT, BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
source=("http://c-ares.haxx.se/download/${_realname}-${pkgver}.tar.gz"{,.asc}
        0001-Use-RPM-compiler-options.patch)
validpgpkeys=('914C533DF9B2ADA2204F586D78E11C6B279D5C91')
sha256sums=('b3612e6617d9682928a1d50c1040de4db6519f977f0b25d40cf1b632900b3efd'
            'SKIP'
            'f00faa8723fd530b027f96b987ef19138628a49afdf52ffb0554b36156fc9d74')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-Use-RPM-compiler-options.patch

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
